<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../css/vant.css" />
</head>
<style>
    html,
    body {
        background-color: #fbf9f9;
    }

    .item {
        width: 100%;
        background-color: #f7f7f9;
        border-bottom: 1px solid #ccc;
    }

    .item .title {
        background-color: #5cd749;
    }

    .item .title span {
        height: 2rem;
        line-height: 2rem;
        font-size: 0.8rem;
        color: #fff;
        font-weight: bold;
        margin: 0 0.5rem;
    }

    .item .title .statu {
        float: right;
        font-weight: normal;

    }

    .item .subtitle {
        padding: 0 3%;
        font-size: 0.8rem;
    }

    .item .subtitle .subItem {
        border-bottom: 1px dashed #ccc;
        padding-bottom: 0.5rem;
    }

    .item .subtitle .subItem p {
        margin-top: 0.5rem;
    }

    .item .subtitle .time {
        height: 2rem;
        padding: 0.5rem 0;
    }

    .item .subtitle .time .timeDetail {
        line-height: 2rem;
    }

    .item .subtitle .time .btn {
        float: right;
        padding: 0.1rem 0.3rem;
        border: 1px solid #4182ce;
        border-radius: 0.5rem;
        color: #4182ce;
        margin-top: 0.25rem;
    }
    .none {
        padding: 1rem;
        font-size: 0.8rem;
        text-align: center;
    }
</style>

<body>
    <div id="app" v-cloak>
        <van-tabs v-model="active" sticky>
            <van-tab title="全部">
                <div class="item" v-for="item in list">
                    <p class="title" @click="prescribeDetail(item.id)">
                        <span>{{item.userName}}</span>
                        <span v-if="item.sex == 1">男</span>
                        <span v-if="item.sex == 2">女</span>
                        <span>{{item.age}}岁</span>
                        <span class="statu" v-if="item.status == 0">审核中</span>
                        <span class="statu" v-if="item.status == -1">未通过</span>
                        <span class="statu" v-if="item.status == 1">已通过</span>
                        <span class="statu" v-if="item.status == 2">已过期</span>
                    </p>
                    <div class="subtitle">
                        <div class="subItem" @click="prescribeDetail(item.id)">
                            <p>诊断结果：{{item.diseases}}</p>
                            <p>药品处方：{{item.prescription}}</p>
                        </div>
                        <div class="time">
                            <span class="timeDetail">{{item.createTime}}</span>
                            <span class="btn" @click="prescribeDetail(item.id)">查看详情</span>
                        </div>
                    </div>
                </div>
            </van-tab>
            <van-tab title="审核中">
                <div class="item" v-for="item in list" v-if="item.status == 0">
                    <p class="title" @click="prescribeDetail(item.id)">
                        <span>{{item.userName}}</span>
                        <span v-if="item.sex == 1">男</span>
                        <span v-if="item.sex == 2">女</span>
                        <span>{{item.age}}岁</span>
                        <span class="statu">审核中</span>
                    </p>
                    <div class="subtitle">
                        <div class="subItem" @click="prescribeDetail(item.id)">
                            <p>诊断结果：{{item.diseases}}</p>
                            <p>药品处方：{{item.prescription}}</p>
                        </div>
                        <div class="time">
                            <span class="timeDetail">{{item.createTime}}</span>
                            <span class="btn" @click="prescribeDetail(item.id)">查看详情</span>
                        </div>
                    </div>
                </div>
            </van-tab>
            <van-tab title="未通过">
                <div class="item" v-for="item in list" v-if="item.status == -1">
                    <p class="title" @click="prescribeDetail(item.id)">
                        <span>{{item.userName}}</span>
                        <span v-if="item.sex == 1">男</span>
                        <span v-if="item.sex == 2">女</span>
                        <span>{{item.age}}岁</span>
                        <span class="statu">未通过</span>
                    </p>
                    <div class="subtitle">
                        <div class="subItem" @click="prescribeDetail(item.id)">
                            <p>诊断结果：{{item.diseases}}</p>
                            <p>药品处方：{{item.prescription}}</p>
                        </div>
                        <div class="time">
                            <span class="timeDetail">{{item.createTime}}</span>
                            <span class="btn" @click="prescribeDetail(item.id)">查看详情</span>
                        </div>
                    </div>
                </div>
            </van-tab>
            <van-tab title="已通过">
                <div class="item" v-for="item in list" v-if="item.status == 1">
                    <p class="title" @click="prescribeDetail(item.id)">
                        <span>{{item.userName}}</span>
                        <span v-if="item.sex == 1">男</span>
                        <span v-if="item.sex == 2">女</span>
                        <span>{{item.age}}岁</span>
                        <span class="statu">已通过</span>
                    </p>
                    <div class="subtitle">
                        <div class="subItem" @click="prescribeDetail(item.id)">
                            <p>诊断结果：{{item.diseases}}</p>
                            <p>药品处方：{{item.prescription}}</p>
                        </div>
                        <div class="time">
                            <span class="timeDetail">{{item.createTime}}</span>
                            <span class="btn" @click="prescribeDetail(item.id)">查看详情</span>
                        </div>
                    </div>
                </div>
            </van-tab>
        </van-tabs>

        <div class="none">已经没有更多了</div>
    </div>
</body>

</html>
<script src="../script/set_root.js"></script>

<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/zepto.min.js"></script>
<script type="text/javascript" src="../script/hb.js"></script>
<script type="text/javascript" src="../script/vue.js"></script>
<script type="text/javascript" src="../script/vant.js"></script>
<script type="text/javascript">
    apiready = function () {
        hb_ready();
        app.getData()
        // alert($api.getStorage("emp"))

        //上拉加载
        api.addEventListener({
            name: 'scrolltobottom',
            extra: {
                threshold: 20 //设置距离底部多少距离时触发，默认值为0，数字类型
            }
        }, function (ret, err) {
            app.page++
            app.getData()
        });
    }
    //使用vue对数据进行绑定
    var app = new Vue({
        el: '#app',
        data: {
            active: 0,
            page: 1,
            list: [],
        },
        methods: {
            prescribeDetail: function (id) {
                api.openWin({
                    name: 'detail_win',
                    url: 'detail_win.html',
                    pageParam: {
                        id: id
                    }
                });
            },
            getData() {
                var data = {
                    doctorId: $api.getStorage("emp").userId,
                    page: app.page,
                    pagesize: 10,
                }
                get_ajax("doctor/prescribe/list/page", data, function (res, err) {
                    // console.log(JSON.stringify(data))
                    // alert(JSON.stringify(res))
                    // alert(JSON.stringify(err))
                    if (res.code == 2000 && app.page == 1) {
                        app.list = res.data.data
                    } else if (res.code == 2000 && app.page > 1) {
                        app.list = app.list.concat(res.data.data)
                    } else {
                        // alert(JSON.stringify(res.msg))
                        app.page--
                    }
                })
            }
        },

    })
</script>